package com.vehicle.service.imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.vehicle.bean.DataGridView;
import com.vehicle.bean.PageVo;
import com.vehicle.mapper.ApplyUseMapper;
import com.vehicle.mapper.OutwardRecordMapper;
import com.vehicle.pojo.ApplyUse;
import com.vehicle.pojo.OutwardRecord;
import com.vehicle.service.BackCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BackCarServiceImpl implements BackCarService {

    @Autowired
    private ApplyUseMapper applyUseMapper;

    @Autowired
    private OutwardRecordMapper outwardRecordMapper;

    //查询所有状态是出车中的申请订单
    @Override
    public DataGridView findAllApplyUse(PageVo pageVo, Integer deptid) {
        DataGridView dataGridView = new DataGridView();
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<ApplyUse> status = applyUseMapper.findApplyUseByStatus(1, deptid);
        PageInfo pageInfo = new PageInfo<>(status);
        dataGridView.setCount(pageInfo.getTotal());
        dataGridView.setData(status);
        return dataGridView;
    }

    @Override
    public void addOutWardRecord(OutwardRecord outwardRecord) {
        outwardRecordMapper.addOutWardRecord(outwardRecord);
    }
}
